package com.lcy.demo.xml;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by PC on 2017/3/29.
 */
@RestController
public class UserController {

    private UserService userService;

    @RequestMapping("/user")
    public User user(@RequestParam(value = "id",defaultValue = "1") Integer id){
        return userService.getUser(id);
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @RequestMapping("/insertUser")
    public Integer insertUser(@RequestParam(value = "name") String name,
                              @RequestParam(value = "age") Integer age,
                              @RequestParam(value = "gender")Integer gender){

        User user = new User();
        user.setAge(age);
        user.setGender(gender);
        user.setName(name);
        return userService.insertUser(user);
    }
}
